package com.lehecai.core.game;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.lehecai.core.IntegerBeanLabelItem;

/**
 * 游戏状态
 * @author He Wang
 */
public class GameStatus extends IntegerBeanLabelItem {

	private static final long serialVersionUID = 7009455804239792650L;
	private static final Logger logger = LoggerFactory.getLogger(GameStatus.class.getName());
	
	private static List<GameStatus> items = new ArrayList<GameStatus>();
	private static List<GameStatus> queryItems = new ArrayList<GameStatus>();
	
	protected GameStatus(String name, int value) {
		this(name, value, false);
	}
	
	protected GameStatus(String name, int value, boolean queryOnly) {
		super(GameStatus.class.getName(), name, value);
		queryItems.add(this);
		
		if (!queryOnly) {
			items.add(this);
		}
	}
	
	public static GameStatus getItem(int value){
		try {
			return (GameStatus)GameStatus.getResult(GameStatus.class.getName(), value);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			return null;
		}
	}
	
	public static List<GameStatus> getItems() {
		return items;
	}
	
	public static List<GameStatus> getQueryItems() {
		return queryItems;
	}

	public static final GameStatus ALL = new GameStatus("全部", -1, true);
	public static final GameStatus GAME_STATUS_CLOSE = new GameStatus("下线", 0);				
	public static final GameStatus GAME_STATUS_ON = new GameStatus("在线", 1);
	public static final GameStatus GAME_STATUS_OFF = new GameStatus("维护", 2);				
	public static final GameStatus GAME_STATUS_FUTURE = new GameStatus("未开放", 3);
	public static final GameStatus GAME_STATUS_INVISIBLE = new GameStatus("离线", 4);
}
